package com.yeung.swordoffer;

public class 整数中1出现的次数 {
    public static void main(String[] args) {
        int i = NumberOf1Between1AndN_Solution(10);
        System.out.println(i);
    }

    public static int NumberOf1Between1AndN_Solution(int n) {
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            sb.append(i);
        }
        String s = sb.toString().replaceAll("[^1]", "");
        return s.length();
    }
}
